package io.renren.utils;

import java.io.Serializable;
import java.util.List;

/**
 * 分页工具类
 */
public class PageUtils implements Serializable {
	private static final long serialVersionUID = 1L;
	//总条数
	private int totalSize;
	//总页数
	private int totalPage;
	//每页条数
	private int pageSize;
	//当前页数
	private int pageNum;
	//列表数据
	private List<?> list;


	/**
	 * 分页
	 * @param list        列表数据
	 * @param totalCount  总记录数
	 * @param pageSize    每页记录数
	 * @param currPage    当前页数
	 */
	public PageUtils(List<?> list, int totalCount, int pageSize, int currPage) {
		this.list = list;
		this.totalSize = totalCount;
		this.pageSize = pageSize;
		this.pageNum = currPage;
		this.totalPage = (int)Math.ceil((double)totalCount/pageSize);
	}
//	public PageUtils(int totalSize, int totalPage, int pageSize, int pageNum, List<?> list) {
//		this.totalSize = totalSize;
//		this.totalPage = totalPage;
//		this.pageSize = pageSize;
//		this.pageNum = pageNum;
//		this.list = list;
//	}



	public int getTotalSize() {
		return totalSize;
	}

	public void setTotalSize(int totalSize) {
		this.totalSize = totalSize;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public List<?> getList() {
		return list;
	}

	public void setList(List<?> list) {
		this.list = list;
	}
}
